package com.pingan.agentbank.aaos.util;


public class JsonUtil {


    /*
    *json字符串转换，将"name":""  和 "name":"null"  和 "name": 和 "name" 统一去掉
    * 只转换一层
    */
    public static String convert(String jsonString){

        StringBuffer sb = new StringBuffer();
        sb.append("{");
        //去掉前后｛｝
        String string = jsonString.substring(1,jsonString.length()-1);
        //都截取为"name":"小王"这种形式
        String[] strings = string.split(",");
        for (String str:strings){
            //没有： 和：是最后一位都舍弃
            int index = str.indexOf(":");
            if (index==-1){
                continue;
            } else if (index==(str.length()-1)){
              continue;
            } else{
                //:分割后为三个字符串的舍弃
                String[] strings1 = str.split(":");
                if (strings1.length == 2){
                    if (strings1[1].equals("\"\"") || strings1[1].equals("\"null\"")){
                        continue;
                    }
                }
            }
            sb.append(str);
            sb.append(",");
        }
        sb = new StringBuffer(sb.substring(0,sb.length()-1));
        sb.append("}");


        return sb.toString();
    }
}
